package com.zanbo.leetcode.increasing_triplet_subsequence;

/**
 * @author zanbo
 * @program Solution
 * @since 2022-01-12 上午 10:45
 */
public class Increasing_triplet_subsequence {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.increasingTriplet(new int[]{1, 3, 4, 2, 6}));
    }
}

class Solution {
    public boolean increasingTriplet(int[] nums) {
        int i = Integer.MAX_VALUE, j = Integer.MAX_VALUE;
        for (int num : nums) {
            if (num <= i) {
                i = num;
            } else if (num <= j) {
                j = num;
            } else {
                return true;
            }
        }
        return false;
    }
}